import 'package:cbec_app/components/common/bottom_nav_bar.dart';
import 'package:cbec_app/utils/AppData.dart';
import 'package:cbec_app/utils/ThemeConfig.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../../components/base/privacy_agreement_dialog.dart';
import '../controller/main_ctr.dart';

///app主路由页
class MainPage extends GetView<MainController> {
  const MainPage({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder<MainController>(builder: ((controller) {
      final filteredTypes = BottomNavBarType.values.where((type) => controller.allowMember || type != BottomNavBarType.member).toList(); // 过滤不允许的页面

      return CupertinoTabScaffold(
        controller: controller.tabController,
        tabBuilder: (context, index) {
          final type = filteredTypes[index]; // 使用过滤后的类型
          return CupertinoTabView(
            builder: (context) {
              return type.getPage(allowMember: controller.allowMember);
            },
          );
        },
        tabBar: CupertinoTabBar(
          height: 40.h,
          items: BottomNavBarTypeExt.getItems(allowMember: controller.allowMember),
          currentIndex: controller.tabController.index,
          onTap: controller.onNavClick,
          activeColor: ThemeConfig.themeColor,
        ),
      );
    }));
  }
}
